From c18ff1c131a33e9d75674dc25b9e54ff88db380f Mon Sep 17 00:00:00 2001 From: justbur Date: Mon, 16 May 2016 15:35:33 -0400 Subject: [PATCH] Add which-key-local-then-key-order To use (setq which-key-sort-order 'which-key-local-then-key-order) See #125 --- which-key.el | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/which-key.el b/which-key.el index b4458933596..d221c6fdcd2 100644 --- a/which-key.el +++ b/which-key.el @@ -1196,6 +1196,21 @@ coming before a prefix. Within these categories order using (and (not apref?) bpref?) (which-key-key-order acons bcons)))) +(defun which-key--local-binding-p (keydesc) + (eq (which-key--safe-lookup-key + (current-local-map) (kbd (which-key--current-key-string (car keydesc)))) + (intern (cdr keydesc)))) + +(defun which-key-local-then-key-order (acons bcons) + "Order first by whether A and/or B is a local binding with +local bindings coming first. Within these categories order using +`which-key-key-order'." + (let ((aloc? (which-key--local-binding-p acons)) + (bloc? (which-key--local-binding-p bcons))) + (if (not (eq aloc? bloc?)) + (and aloc? (not bloc?)) + (which-key-key-order acons bcons)))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Functions for retrieving and formatting keys -- 2.30.2